package bg.cinema_system.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import bg.cinema_system.global.ConnectionJDBC;

public class HallDAO {

	public static int getHallNumber(int hall_id) throws SQLException {
		
		Connection dbConnection = ConnectionJDBC.getConnection();

		if (dbConnection == null) {
			throw new SQLException("Class HallDAO: Can't get database connection");
		}

		String sqlStatement = "SELECT halls.number_hall FROM cinema.halls " 
		+ "WHERE halls.hall_id = ?";

		PreparedStatement ps = dbConnection.prepareStatement(sqlStatement);
		ps.setInt(1, hall_id);

		// Get customer data from database
		ResultSet result = ps.executeQuery();

		int hall_number = -1;

		if (result.next()) {
			hall_number = result.getInt("number_hall");
		}

		return hall_number;
	}

}
